import Vue from 'vue'
import App from './App.vue'
import router from './router/index'

import { isInSkystark, registerAppEnter, registerAppLeave, getMountNode } from './childApp'

Vue.config.productionTip = false


if (isInSkystark()) {

  let vm = null

  registerAppEnter(() => {
    const mountNode = getMountNode()
    vm = new Vue({
      router,
      render: h => h(App),
    }).$mount()

    mountNode.innerHTML = ""
    mountNode.appendChild(vm.$el)
  })

  registerAppLeave(() => {
    vm && vm.$destroy()
  })

} else {

  new Vue({
    router,
    render: h => h(App),
  }).$mount("#app")

}
